import {useStore} from 'vuex'
import {computed} from 'vue'
export const useStoreHook = ()=>{
	const store = useStore()
	return {
		store
	}
}

export const useStoreState = (path)=>{
	const store = useStore()
	let arr = path.split('/')
	let key = arr[1]
	return {
		[key]:computed(()=>{
			return store.state[arr[0]][arr[1]]
		})
	}
}


// useMapMutations([
// 	'cart/cartCheckMut',
// 	'cart/cartAllCheckMut'
// ])
export const useMapMutations = (options)=>{
	const store = useStore()
	let obj = {}
	options.forEach(item=>{
		let arr = item.split('/')
		obj[arr[1]] = (arg)=>{
			store.commit(item,arg)
		}
	})
	return obj
}